package contas

def login = {
	if (request.method == "GET") {
		session.userId = null
		def user = new User()
	}
	else {
		def user =
				User.findByUserIdAndPassword(params.userId,
				params.password)
		if (user) {
			session.userId = user.userId
			redirect(controller:'user')
		}
		else {
			flash['message'] = 'Please enter a valid user ID and password'
		}
	}
}

def logout = {
	session.userId = null
	flash['message'] = 'Successfully logged out'
	redirect(controller:'race', action:'search')
}
